var stringUtils = function () {

    /**
     * 拼接url参数
     * @param url
     * @param params
     */
    function splicingUrlParams(url, params) {
        var newUrl = url;
        if (params) {
            for (var key in params) {
                if (newUrl.indexOf('?') != -1) {
                    newUrl += '&' + key + '=' + params[key]
                } else {
                    newUrl += '?' + key + '=' + params[key]
                }
            }
        }
        return newUrl;

    }

    /**
     * 获取url的参数
     * 参考：http://www.runoob.com/w3cnote/js-get-url-param.html
     * @param variable
     * @returns {*}
     */
    function getQueryVariable(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == variable) {
                return pair[1];
            }
        }
        return (false);
    }

    /**
     * 字符串添加br
     * @param text 值
     * @param len 多少位開始
     * @returns {*}
     */
    var subStr = function (text, len) {
        if (text && text.length > len) {
            var re = '';
            for (var i = 0, j = 1; i < text.length; i++, j++) {
                if (j && j % len == 0) {
                    re += '<br />';
                } else {
                    re += text[i];
                }
            }
            return re;
        } else {
            return text;
        }
    }

    return {
        splicingUrlParams: splicingUrlParams,
        getQueryVariable: getQueryVariable,
        subStr: subStr
    }
}()